import { MockMethod } from 'vite-plugin-mock';
import { resultSuccess } from '../_util';
import { mock } from 'mockjs';

const goodsList = mock({
  'data|30': [
    {
      goodsId: '@increment',
      goodsName: 'CONVERSE匡威官方 All Star时尚百搭帆布鞋女鞋新款休闲鞋571867C',
      siteId: 1,
      siteName: '',
      goodsImage:
        'upload/1/common/images/20200805/20200805013737159660585737366.png,upload/1/common/images/20200805/20200805013737159660585737396.png',
      goodsState: 2,
      price: '499.00',
      goodsStock: 400,
      goodsStockAlarm: 0,
      createTime: '@date(yyyy-MM-dd HH:mm:ss)',
      saleNum: 0,
      isVirtual: 0,
      goodsClass: 1,
      goodsClassName: '实物商品',
      isFenxiao: 0,
      fenxiaoType: 1,
      promotionAddon: '',
      skuId: 15,
      isConsumeDiscount: 0,
      discountConfig: 0,
      discountMethod: '',
      sort: '@integer(1,20)',
      labelId: 0,
      labelName: '',
      isDelete: 0,
      virtualDeliverType: '',
      //新增
      goodsStateText: '销售中',
    },
  ],
});

const goodsInfo = mock({
  goodsId: '@increment',
  goodsName: 'CONVERSE匡威官方 All Star时尚百搭帆布鞋女鞋新款休闲鞋571867C',
  introduction: '时尚百搭帆布鞋女鞋新款休闲鞋571867C',
  goodsImageList: [
    'http://www.lvais.com/upload/2022/11/15/20221115112138641.jpg',
    'http://www.lvais.com/upload/2019/08/07/20190807100514186.jpg',
  ],
  keyword: '是客户交,深刻的回复',
  categoryId: [1, 2, 3],
  goodsState: 2,
  price: '499.00',
  goodsStock: 400,
  goodsStockAlarm: 0,
  createTime: '@date(yyyy-MM-dd HH:mm:ss)',
  saleNum: 0,
  isVirtual: 0,
  goodsClass: 1,
  goodsClassName: '实物商品',
  isFenxiao: 0,
  fenxiaoType: 1,
  promotionAddon: '',
  skuId: 15,
  isConsumeDiscount: 0,
  discountConfig: 0,
  discountMethod: '',
  sort: '@integer(1,20)',
  labelId: 0,
  labelName: '',
  isDelete: 0,
  virtualDeliverType: '',
  //新增
  goodsStateText: '销售中',
});

export default [
  //分页
  {
    url: '/mock-api/v1/goods/page',
    timeout: 100,
    method: 'post',
    response: () => {
      return resultSuccess({ list: goodsList.data.slice(0, 6), total: 10 });
    },
  },
  {
    url: '/mock-api/v1/goods/info',
    timeout: 100,
    method: 'post',
    response: () => {
      return resultSuccess(goodsInfo);
    },
  },
] as MockMethod[];
